<?php
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>
<?php
/**
 * Edit customer address template
 *
 * @var \Magento\Customer\Block\Address\Edit $block
 */
?>
<form class="form-address-edit" action="<?php echo $block->escapeUrl($block->getSaveUrl()) ?>" method="post" id="form-validate" enctype="multipart/form-data" data-hasrequired="<?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr(__('* Required Fields')) ?>">
    <fieldset class="fieldset">
        <legend class="legend"><span><?php echo $block->escapeHtml(__('Contact Information')) ?></span></legend><br>
        <?php echo $block->getBlockHtml('formkey')?>
        <input type="hidden" name="success_url" value="<?php echo $block->escapeUrl($block->getSuccessUrl()) ?>">
        <input type="hidden" name="error_url" value="<?php echo $block->escapeUrl($block->getErrorUrl()) ?>">
        <?php echo $block->getNameBlockHtml() ?>
        <div class="field company">
            <label class="label" for="company"><span><?php echo $block->escapeHtml(__('Company')) ?></span></label>
            <div class="control">
                <input type="text" name="company" id="company" title="<?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr(__('Company')) ?>" value="<?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr($block->getAddress()->getCompany()) ?>" class="input-text <?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr($this->helper(\Magento\Customer\Helper\Address::class)->getAttributeValidationClass('company')) ?>">
            </div>
        </div>
        <div class="field telephone required">
            <label class="label" for="telephone"><span><?php echo $block->escapeHtml(__('Phone Number')) ?></span></label>
            <div class="control">
                <input type="text" name="telephone" value="<?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr($block->getAddress()->getTelephone()) ?>" title="<?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr(__('Phone Number')) ?>" class="input-text <?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr($this->helper(\Magento\Customer\Helper\Address::class)->getAttributeValidationClass('telephone')) ?>" id="telephone">
            </div>
        </div>
        <div class="field fax">
            <label class="label" for="fax"><span><?php echo $block->escapeHtml(__('Fax')) ?></span></label>
            <div class="control">
                <input type="text" name="fax" id="fax" title="<?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr(__('Fax')) ?>" value="<?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr($block->getAddress()->getFax()) ?>" class="input-text <?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr($this->helper(\Magento\Customer\Helper\Address::class)->getAttributeValidationClass('fax')) ?>">
            </div>
        </div>
    </fieldset>
    <fieldset class="fieldset">
        <legend class="legend"><span><?php echo $block->escapeHtml(__('Address')) ?></span></legend><br>
        <?php $_streetValidationClass = $this->helper(\Magento\Customer\Helper\Address::class)->getAttributeValidationClass('street'); ?>
        <div class="field street required">
            <label for="street_1" class="label"><span><?php echo $block->escapeHtml(__('Street Address')) ?></span></label>
            <div class="control">
                <input type="text" name="street[]" value="<?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr($block->getStreetLine(1)) ?>" title="<?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr(__('Street Address')) ?>" id="street_1" class="input-text <?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr($_streetValidationClass) ?>"  />
                <div class="nested">
                    <?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
                    <?php for ($_i = 1, $_n = $this->helper(\Magento\Customer\Helper\Address::class)->getStreetLines(); $_i < $_n; $_i++): ?>
                        <div class="field additional">
                            <label class="label" for="street_<?php /* @escapeNotVerified */ echo $_i+1 ?>">
                                <span><?php echo $block->escapeHtml(__('Street Address %1', $_i + 1)) ?></span>
                            </label>
                            <div class="control">
                                <input type="text" name="street[]" value="<?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr($block->getStreetLine($_i+1)) ?>" title="<?php  echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr(__('Street Address %1', $_i + 1)) ?>" id="street_<?php /* @escapeNotVerified */ echo $_i+1 ?>" class="input-text <?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr($_streetValidationClass) ?>">
                            </div>
                        </div>
                    <?php endfor; ?>
                </div>
            </div>
        </div>

        <?php if ($this->helper(\Magento\Customer\Helper\Address::class)->isVatAttributeVisible()) : ?>
            <div class="field taxvat">
                <label class="label" for="vat_id"><span><?php echo $block->escapeHtml(__('VAT Number')) ?></span></label>
                <div class="control">
                    <input type="text" name="vat_id" value="<?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr($block->getAddress()->getVatId()) ?>" title="<?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr(__('VAT Number')) ?>" class="input-text <?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr($this->helper(\Magento\Customer\Helper\Address::class)->getAttributeValidationClass('vat_id')) ?>" id="vat_id">
                </div>
            </div>
        <?php endif; ?>
        <div class="field city required">
            <label class="label" for="city"><span><?php echo $block->escapeHtml(__('City')) ?></span></label>
            <div class="control">
                <input type="text" name="city" value="<?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr($block->getAddress()->getCity()) ?>" title="<?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr(__('City')) ?>" class="input-text <?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr($this->helper(\Magento\Customer\Helper\Address::class)->getAttributeValidationClass('city')) ?>" id="city">
            </div>
        </div>
        <div class="field region required">
            <label class="label" for="region_id"><span><?php echo $block->escapeHtml(__('State/Province')) ?></span></label>
            <div class="control">
                <select id="region_id" name="region_id" title="<?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr(__('State/Province')) ?>" class="validate-select" <?php echo(!$block->getConfig('general/region/display_all')) ? ' disabled="disabled"' : '';?>>
                    <option value=""><?php echo $block->escapeHtml(__('Please select a region, state or province.')) ?></option>
                </select>
                <input type="text" id="region" name="region" value="<?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr($block->getRegion()) ?>"  title="<?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr(__('State/Province')) ?>" class="input-text <?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr($this->helper(\Magento\Customer\Helper\Address::class)->getAttributeValidationClass('region')) ?>"<?php echo(!$block->getConfig('general/region/display_all')) ? ' disabled="disabled"' : '';?>/>
            </div>
        </div>
        <div class="field zip required">
            <label class="label" for="zip"><span><?php echo $block->escapeHtml(__('Zip/Postal Code')) ?></span></label>
            <div class="control">
                <input type="text" name="postcode" value="<?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr($block->getAddress()->getPostcode()) ?>" title="<?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr(__('Zip/Postal Code')) ?>" id="zip" class="input-text validate-zip-international <?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr($this->helper(\Magento\Customer\Helper\Address::class)->getAttributeValidationClass('postcode')) ?>">
            </div>
        </div>
        <div class="field country required">
            <label class="label" for="country"><span><?php echo $block->escapeHtml(__('Country')) ?></span></label>
            <div class="control">
                <?php echo $block->getCountryHtmlSelect() ?>
            </div>
        </div>

        <?php if ($block->isDefaultBilling()): ?>
            <div class="message info"><?php echo $block->escapeHtml(__("It's a default billing address.")) ?></div>
        <?php elseif ($block->canSetAsDefaultBilling()): ?>
            <div class="field choice set billing">
                <input type="checkbox" id="primary_billing" name="default_billing" value="1" class="checkbox">
                <label class="label" for="primary_billing"><span><?php echo $block->escapeHtml(__('Use as my default billing address')) ?></span></label>
            </div>
        <?php else: ?>
            <input type="hidden" name="default_billing" value="1" />
        <?php endif; ?>

        <?php if ($block->isDefaultShipping()): ?>
            <div class="message info"><?php echo $block->escapeHtml(__("It's a default shipping address.")) ?></div>
        <?php elseif ($block->canSetAsDefaultShipping()): ?>
            <div class="field choice set shipping">
                <input type="checkbox" id="primary_shipping" name="default_shipping" value="1" class="checkbox">
                <label class="label" for="primary_shipping"><span><?php echo $block->escapeHtml(__('Use as my default shipping address')) ?></span></label>
            </div>
        <?php else: ?>
            <input type="hidden" name="default_shipping" value="1">
        <?php endif; ?>
    </fieldset>
    <div class="actions-toolbar">
        <div class="primary">
            <button type="submit" class="action save primary" data-action="save-address" title="<?php echo $this->helper(\Magento\Framework\EscapeHelper::class)->escapeHtmlAttr(__('Save Address')) ?>">
                <span><?php echo $block->escapeHtml(__('Save Address')) ?></span>
            </button>
        </div>
        <div class="secondary">
            <a class="action back" href="<?php echo $block->escapeUrl($block->getBackUrl()) ?>"><span><?php echo $block->escapeHtml(__('Go back')) ?></span></a>
        </div>
    </div>
</form>
<script type="text/x-magento-init">
    {
        "#form-validate": {
            "validation": {}
        },
        "#country": {
            "regionUpdater": {
                "optionalRegionAllowed": <?php /* @escapeNotVerified */ echo($block->getConfig('general/region/display_all') ? 'true' : 'false'); ?>,
                "regionListId": "#region_id",
                "regionInputId": "#region",
                "postcodeId": "#zip",
                "form": "#form-validate",
                "regionJson": <?php /* @escapeNotVerified */ echo $this->helper(\Magento\Directory\Helper\Data::class)->getRegionJson() ?>,
                "defaultRegion": "<?php echo (int) $block->getRegionId() ?>",
                "countriesWithOptionalZip": <?php /* @escapeNotVerified */ echo $this->helper(\Magento\Directory\Helper\Data::class)->getCountriesWithOptionalZip(true) ?>
            }
        }
    }
</script>
